<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
</script>
<body>
<div>
    <h2>Login</h2>
    <input type="text" id="username">
    <input type="password" id="pwd">
    <button id="login">Login</button>
</div>
<div>
    <h2>FileList</h2>
    <button id="filelist">List Files</button>
</div>
<div>
    <h2>FileUpload</h2>
    <form action="http://192.168.124.16:8989/transfer/upload" enctype="multipart/form-data" method="post">
        <input type="file" name="src">
        <input type="submit">
    </form>
</div>
</body>
<script>

    /*http://192.168.124.16:8989/transfer*/
    $(function() {

        var accessToken = null;

        $("#filelist").click(function () {
            alert("Bearer " + accessToken)
            $.ajax(({
                url: "http://localhost:8989/transfer/files",
                method: "GET",
                success:  function (resp) {
                    console.log(resp)
                }
            }))
        })

        $("#login").click(function () {
            var u = $("#username").val()
            var p = $("#pwd").val()

            data = {
                "username": u,
                "password": p
            }
                $.ajax({
                    url: "http://localhost:8989/login",
                    contentType: "application/x-www-form-urlencoded",
                    method: "POST",
                    data: data,
                    success: function (t) {
                        console.log(t)
                        accessToken = t.access_token
                        alert("Bearer " + accessToken)
                    }
                })

        })
    })
</script>
</html>